<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="js/react.development.js"></script>
    <script type="text/javascript" src="js/react-dom.development.js"></script>
    <script type="text/javascript" src="js/babel.min.js"></script>
</head>
<body>
    <div id="root">
    
    </div>
    <script type="text/babel">
        class Myform extends React.Component{
            constructor(props) {
                super(props);
                this.state = {
                    iNum:10,
                }
                console.log('----constructor----');
            }

            progIncrease=()=>{
                console.log('----progIncrease----');
                this.setState({
                    iNum:this.state.iNum + 1
                })
            }

            shouldComponentUpdate() {
                console.log('----shouComponentUpdate----');
                return true
            }

            render() {
                console.log('----render----');
                return (
                    <div>
                        <p>{this.state.iNum}</p>
                        <input onClick={this.progIncrease} type="button" value="递增按钮"/>
                    </div>
                )
            }

            componentDidUpdate() {
                console.log('----componentDidUpdate----');
            }

            componentDidMount() {
                console.log('----componentDidMount----');
            }

            componentWillUnmount() {
                console.log('----componentWillUnmount----');
            }
        }
        ReactDOM.render(<Myform/>, document.getElementById('root'));
        setTimeout(() => {
            ReactDOM.render(<h2>改变渲染树</h2>, document.getElementById('root'));
        }, 5000);
    </script>
</body>
</html>